package com.fingard.dsp.bank.reqrespobj.transaction;

import com.fingard.FGBiz;
import com.fingard.dsp.bank.directbank.specialDeal.BankAreaHelper;
import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RequestBase;
import com.fingard.xml.XmlTextReader;

import java.util.Arrays;
import java.util.HashSet;

public class Req7515TodayTrans extends RequestBase {

    //账号ID（民生银行全球现金池使用）alon Created 2019-12-06
    public String accountId = "";

    //同行标志（民生银行全球现金池使用）alon Created 2019-12-05
    //同行（1-境内分行账户；2-境外分行账户）；他行：3-他行账户
    public String sameBank;

    public String actArea = "";
    public String actCur = "";
    public String actNum = "";
    public String isSpecialAct = "";
    public String queryUrid = "";
    //账户类型（3-保证金）
    public String savingType = "";
    //上级账户
    public String higherLevelAct;
    /*账户机构类型
    中信银行附属账户：2
    农行多级账簿：3
    工行全球现金池：4
    工行账户管家：5
    中信银行附属虚拟账户：6
    */
    public String actBankType="";
    //上一笔柜员号
    public String tranNo;
    public String isReqFromDsp="";

    //外资银行新增字段
    //银行类型
    public String bankType;
    //为账户时区的当日日期
    public String zoneFrDate;
    //付款方IBAN
    public String payIBAN;
    //时区
    public String timeZone;
    //账户所在行的swiftcode
    public String swiftCode;
    //是否虚拟户
    public boolean isVirtual;
    //直联账户权限
    public HashSet<String> directRight;

    private XmlTextReader xmlReader;

    public Req7515TodayTrans(XmlTextReader p_xmlReader, ReqRespHeader p_header) throws Exception {
        reqHeader = p_header;
        xmlReader = p_xmlReader;
        actArea = xmlReader.getSimpleText("ActArea");
        if (FGBiz.dspCenter.convertBankArea) {
            BankAreaHelper bankAreaHelper=new BankAreaHelper(p_header.bankCode,actArea,"");
            bankAreaHelper.toBank();
            actArea=bankAreaHelper.bankAreaCode;
        }
        accountId = xmlReader.getSimpleText("AccountId");
        sameBank = xmlReader.getSimpleText("SameBank");
        actCur = xmlReader.getSimpleTextNotNull("ActCur");
        actNum = xmlReader.getSimpleText("ActNum");
        isSpecialAct = xmlReader.getSimpleTextNotNull("IsSpecialAct");
        queryUrid = xmlReader.getSimpleTextNotNull("QueryUrid");
        savingType = xmlReader.getSimpleTextNotNull("SavingType");
        higherLevelAct = xmlReader.getSimpleTextNotNull("HigherLevelAct");
        actBankType=xmlReader.getSimpleTextNotNull("ActBankType");
        tranNo=xmlReader.getSimpleTextNotNull("TranNo");
        isReqFromDsp = xmlReader.getSimpleTextNotNull("IsReqFromDsp");
        bankType  = xmlReader.getSimpleTextNotNull("BankType");
        zoneFrDate  = xmlReader.getSimpleTextNotNull("ZoneFrDate");
        payIBAN  = xmlReader.getSimpleTextNotNull("PayIBAN");
        timeZone  = xmlReader.getSimpleTextNotNull("TimeZone");
        swiftCode = xmlReader.getSimpleTextNotNull("swiftcode");
        if ("1".equals(xmlReader.getSimpleText("ISNOTIONAL"))) {
            isVirtual = true;
        } else {
            isVirtual = false;
        }
        String[] directRights = xmlReader.getSimpleTextNotNull("DirectRight").split(",");
        directRight = new HashSet<String>(Arrays.asList(directRights));
    }

    public String getOriReqXml(){
        return xmlReader.getOriXmlString();
    }

    public XmlTextReader getXmlReader() {
        return xmlReader;
    }
}